<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1251">
  <link href="/css/livesearch.css" rel="stylesheet" type="text/css">
  
  <script src="/js/jquery.js"></script>
  <script src="/js/JsHttpRequest.js"></script>
  <script src="/js/livesearch.js"></script>
  
  <script>
    $(document).ready(function(){
      $('.e').click(function(){
        if( $('#exersize').get().length>0 ){
          remove_ls();
				}
        $(this).hide().after( '<input type="text" id="exersize" value="TEST VALUE">' );
				//LIVESAEARCH
				liveSearch.init($('#exersize')[0],{
					attr_set:'placeholder,name,id,value',
					make_query:function(ls_obj){
					  return {
					    'mode':'search_ex',
							'query':$(ls_obj).val()
						}
					},
					search_url:'/z_tmp/search.php',
					//onInit:function(e){ },
					onResponse:function( respJS,e ){
						$('ul:first li a',e.liveSearch.results).click(function(){
							alert(this);
						});
					}
					//,onResponseText:my_resp_text
				});
			});
			
			$('#tst_rem').click(function(){
			  remove_ls();
			  return false;
			});
		});
		
		function remove_ls(){
			liveSearch.remove('#exersize');
		  $('#exersize').prev().show();
		  $('#exersize').remove();
		}
		function my_resp_text(text,obj){
		  alert('my resp text: '+text)
		}
  </script>
  <title></title>
  </head>
  <body>
		<div style="width:200px; float:left;"><span class="e">TEST1</span></div>
		<div style="width:200px; float:left;"><span class="e">TEST2</span></div>
		<a href="#" id="tst_rem">remove</a>
  </body>
</html>
